// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StreamNotFoundException.cs" company="">
//   
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace ExecutionTool.Common
{
    using System.IO;

    /// <summary>
    /// Class to allow stream read operations to raise specific errors if the stream
    /// is not found in the file.
    /// </summary>
    public class StreamNotFoundException : FileNotFoundException
    {
        #region Fields

        private readonly string _stream = string.Empty;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Constructor called with the name of the file and stream which was
        /// unsuccessfully opened.
        /// </summary>
        /// <param name="file">Fully qualified name of the file in which the stream
        /// was supposed to reside.</param>
        /// <param name="stream">Stream within the file to open.</param>
        public StreamNotFoundException(string file, string stream)
            : base(string.Empty, file)
        {
            this._stream = stream;
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Overridden Message property to return a concise string describing the
        /// exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return "Stream \"" + this._stream + "\" not found in \"" + base.FileName + "\"";
            }
        }

        /// <summary>
        /// Read-only property to allow the user to query the exception to determine
        /// the name of the stream that couldn't be found.
        /// </summary>
        public string Stream
        {
            get
            {
                return this._stream;
            }
        }

        #endregion
    }
}
